﻿Imports DTO
Imports System.Data.SqlClient
Public Class CPhieuThuTienPhatDAO
    Public Function ThemPhieuThu(ByRef phieuthu As CPhieuThuTienPhatDTO) As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspThemPhieuThu", cn)
            Dim para As SqlParameter = New SqlParameter("@madocgia", phieuthu.MaDocGia)
            cm.Parameters.Add(para)
            para = New SqlParameter("@manhanvien", phieuthu.MaNhanVien)
            cm.Parameters.Add(para)
            para = New SqlParameter("@sotienthu", phieuthu.SoTienThu)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tienno", phieuthu.TienNo)
            cm.Parameters.Add(para)
            para = New SqlParameter("@conlai", phieuthu.ConLai)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ma", 0)
            para.Direction = ParameterDirection.Output
            cm.Parameters.Add(para)
            Dim n As Integer = cm.ExecuteNonQuery()
            cn.Close()
            phieuthu.Ma = cm.Parameters("@ma").Value
            Return n

        End Using
    End Function
End Class
